package com.ruoyi.yljf.controller.AppController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.yljf.domain.dto.CreateDTO.RecordCreateDTO;
import com.ruoyi.yljf.domain.dto.RecordDTO;
import com.ruoyi.yljf.domain.vo.RecordVO;
import com.ruoyi.yljf.service.IRecordService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/record")
public class ApiRecordController extends BaseController {

    @Resource
    private IRecordService recordService;

//    /**
//     * 查询学习记录
//     * @return
//     */
//    @GetMapping("/list")
//    public AjaxResult recordList(){
//        List<Record> list = recordService.selectRecordList(new Record());
//        return AjaxResult.success(list);
//    }

    /**
     * 按类型查询学习记录列表
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo recordByType(RecordDTO dto){
        startPage();
        List<RecordVO> list = recordService.recordByType(dto);
        List<RecordVO> recordVOS = recordService.recordByType(list, dto.getType());
        return getDataTableInfo(recordVOS,list);

    }


    /**
     *  新增学习记录列表
     * @return
     */
    @PostMapping("/addRecord")
    public AjaxResult addRecord(@RequestBody RecordCreateDTO dto ){
        List<RecordVO> list = recordService.addRecord(dto);
        return AjaxResult.success();
    }
}

